package com.spsoft.vatoutinv.controller.statistics;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.spsoft.core.annotation.AnonymousAccess;
import com.spsoft.core.annotation.Log;
import com.spsoft.core.controller.BaseController;
import com.spsoft.core.enums.LogActionType;
import com.spsoft.core.enums.LogMenuEnum;
import com.spsoft.core.model.Result;
import com.spsoft.vatoutinv.model.dto.statistics.invoiceInfoTestDto;
import com.spsoft.vatoutinv.model.vo.statistics.InvoiceInfoTestVo;
import com.spsoft.vatoutinv.service.vmsfulloutinvoice.VmsFullOutInvoiceDetailsTestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api("顶层描述-开票信息统计")
@RequiredArgsConstructor
@Validated
@Slf4j
@RestController // 最外层都需要这个,  --- @RestController是一个组合注解，它由@Controller和@ResponseBody组成。当一个类或方法上标注了@RestController，它的作用主要包括：
@RequestMapping("/testStatistics") // 这里为啥加了vatoutinv ?? application.properties有配置
//控制器标识：@RestController告诉Spring框架该类是一个控制器，专门用来处理HTTP请求。
public class VmsStatisticsInfoTestController extends BaseController {
    @Autowired
    VmsFullOutInvoiceDetailsTestService vmsFullOutInvoiceDetailsTestService;

    @ApiOperation("二层单接口描述")

    // AnonymousAccess是core里的注解, value是路径,method是方法,permissionCode是指定 哪些权限可以用
    @AnonymousAccess(path = "invoiceInformation", method = RequestMethod.POST, permissionCode = "") // 使用PostMapping一直报错,改成这个权限的
//    @PostMapping("/invoiceInformation")

    @Log(value = "统计相关-发票信息统计Test", type = LogActionType.SELECT, menuName = LogMenuEnum.STATISTICS)
    public Result<IPage<InvoiceInfoTestVo>> invoiceInformation(@RequestBody @Validated invoiceInfoTestDto dto){
        System.out.println(dto);
        IPage<InvoiceInfoTestVo> data = vmsFullOutInvoiceDetailsTestService.getData(dto);
        System.out.println(data);
        return Result.OK(data);
    }
}
